<!--
    @author Yancy Zhang
    @date 2022/4/5
    @description 文章列表页面
-->
<template>
  <div class="artilce-detail" style="background-repeat:no-repeat; background-attachment:fixed;background-size:cover;background-image: url(https://img.xjh.me/random_img.php?type=bg&ctype=nature&return=302);">
    <div>
      <Header></Header>
    </div>
    <div class="main">
      <div class="auto-play blog-render-container">
        <div class="blog-head" :style="{backgroundImage: 'url('+ blog.blog_cover_img+')'}">
          <div class="blog-head-inner">
            <h2>{{blog.blog_title}}</h2>
            <p>发布于: {{blog.blog_post_time | formatTime}} | 作者：YancyZhang</p>
          </div>
        </div>
        <div class="blog-desc">
          <p>{{ blog.blog_desc }}</p>
        </div>
        <div>
          <mavon-editor
              v-model="blog.blog_md_content"
              :subfield="false"
              :boxShadow="false"
              defaultOpen="preview"
              :toolbarsFlag="false"
          />
        </div>
      </div>
    </div>
    <div>
      <Footer></Footer>
    </div>
  </div>
</template>
<script>
import Header from "../../components/Header";
import Footer from "../../components/Footer";
import {getBlogDetail} from "../../http/api";
export default {
  name: "ArticleDetail",
  components:{
    Header,
    Footer
  },
  data() {
    return {
      blog: {},
    };
  },
  created() {
    window.scrollTo(0, 0);//回到顶部
    getBlogDetail(this.$route.params.id).then(res=>{
      this.blog = res;
    }).catch(error=>{
      this.$message.error(error);
    })
  }
}
</script>

<style scoped>
.blog-head {
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  height: 16.25rem;
  margin-bottom: 1rem;
}
.blog-head-inner{
  background: rgba(0,0,0,.5);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  height: 100%;
  width: 100%;
}
.blog-head-inner h2{
  padding: 10px;
}
.blog-desc{
  border-left: 5px solid black;
  padding: 0 5px;
}
.blog-render-container{
  background-color: white;
  padding: 10px;
}
@media screen and (max-width: 1000px){
  .blog-render-container{
    padding: 0;
  }
}
</style>
